package com.cy.pj.module.comtorller;

import com.cy.pj.module.pojo.ResponseResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class JsonContorller {

    @RequestMapping("/doConvertMapToJson")
    @ResponseBody
    public List<Map<String,Object>> doConvertMapToJson(){
        List<Map<String,Object>> list = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("name","tony");
        map.put("stat","true");
        list.add(map);
        map.put("name","Json");
        map.put("stat","true");
        list.add(map);
        return list;
    }

    @RequestMapping("/doConvertResponseToJson")
    @ResponseBody//将不再响应为view  响应为json格式数据
    public ResponseResult doConvertResponseToJson(){
        ResponseResult result = new ResponseResult();
        result.setCode(200);
        result.setMessage("ok");
        return result;
    }
}
